<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.controller');
class NvControllerPropinsi extends JController{

	function __construct(){
		parent::__construct();
		$this->registerTask( 'add'  , 	'edit' );
	}

	function display()
	{
		JRequest::setVar( 'view'  , 'propinsi');
		JRequest::setVar( 'edit', false );
		
		parent::display();
	}

	function edit()
	{
		JRequest::setVar( 'view', 'propinsi' );
		JRequest::setVar( 'layout', 'form'  );
		JRequest::setVar('hidemainmenu', 1);

		parent::display();
	}

	function save()
	{
		$model = $this->getModel('propinsi');

		$post	= JRequest::get('post');
		$cid	= JRequest::getVar( 'cid', array(0), 'post', 'array' );
		$post['propinsi_id'] = (int) $cid[0];

		if ($model->store($post)) {
			$msg = JText::_( 'Data disimpan' );
		} else {
			$msg = JText::_( 'Data tidak bisa disimpan' );
		}

		$this->setRedirect(JRoute::_('index.php?option=com_nv&view=propinsi', false), $msg);
	}

	function remove(){
		$model = $this->getModel('objek');
		if(!$model->delete()) {
			$msg = JText::_( 'Data tidak bisa dihapus' );
		} else {
			$msg = JText::_( 'Data telah terhapus' );
		}

		$link = 'index.php?option=com_nv&view=propinsi';
		$this->setRedirect($link,$msg);
	}
	
	function cancel(){
		$link = 'index.php?option=com_nv&controller=propinsi';
		$this->setRedirect($link);
	}	
}
?>
